import 'package:json_annotation/json_annotation.dart';

part 'lessonreview.g.dart';

@JsonSerializable()
class PreLessonReview {
  List<ClassInfo> classInfo;

  PreLessonReview({this.classInfo});

  PreLessonReview.fromJson(Map<String, dynamic> json) {
    if (json['classInfo'] != null) {
      classInfo = new List<ClassInfo>();
      json['classInfo'].forEach((v) {
        classInfo.add(new ClassInfo.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.classInfo != null) {
      data['classInfo'] = this.classInfo.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class ClassInfo {
  String classId;
  String className;
  int joinCnt;
  int unJoinCnt;
  String joinRate;
  List<UserInfo> userInfo;

  ClassInfo(
      {this.classId,
      this.className,
      this.joinCnt,
      this.unJoinCnt,
      this.joinRate,
      this.userInfo});

  ClassInfo.fromJson(Map<String, dynamic> json) {
    classId = json['classId'];
    className = json['className'];
    joinCnt = json['joinCnt'];
    unJoinCnt = json['unJoinCnt'];
    joinRate = json['joinRate'];
    if (json['userInfo'] != null) {
      userInfo = new List<UserInfo>();
      json['userInfo'].forEach((v) {
        userInfo.add(new UserInfo.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['classId'] = this.classId;
    data['className'] = this.className;
    data['joinCnt'] = this.joinCnt;
    data['unJoinCnt'] = this.unJoinCnt;
    data['joinRate'] = this.joinRate;
    if (this.userInfo != null) {
      data['userInfo'] = this.userInfo.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class UserInfo {
  String userId;
  String userName;
  String flag;

  UserInfo({this.userId, this.userName, this.flag});

  UserInfo.fromJson(Map<String, dynamic> json) {
    userId = json['userId'];
    userName = json['userName'];
    flag = json['flag'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['userId'] = this.userId;
    data['userName'] = this.userName;
    data['flag'] = this.flag;
    return data;
  }
}
